public class test {
    public static void main(String[] args) {
        //利用JAVA原生类Math方法求最大值
        int a = 10;
        int b = 20;
        double c = 10.1;
        double d = 11.1;
        double e = 3.12;
        int ret1 = max(a,b);
        double ret2 = max(c,d,e);
        System.out.println(ret1);
        System.out.println(ret2);

    }
    public static int max(int x,int y){
        return Math.max(x,y);
    }
    public static double max(double x,double y,double z){
        double ret = Math.max(x,y);
        return Math.max(ret,z);
    }

    //汉若塔问题
    public static void main1(String[] args) {
        Hannoi(1,'A','B','C');
        System.out.println();
        Hannoi(2,'A','B','C');
        System.out.println();
        Hannoi(3,'A','B','C');
        System.out.println();
        Hannoi(4,'A','B','C');

    }
    //模拟移动塔的过程
    public static void move(char pos1,char pos2){
        System.out.printf(" %c->%c ",pos1,pos2);
    }
    //n：表示塔的层数
    //pos1表示初始位置
    //pos2表示过度位置
    //pos3表示终止位置
    public static void Hannoi(int n,char pos1,char pos2,char pos3){
        if(n == 1){
            move(pos1,pos3);
        }else{
            Hannoi(n-1,pos1,pos3,pos2);//通过终止位置pos3将pos1移动到pos2上
            move(pos1,pos3);
            Hannoi(n-1,pos2,pos2,pos3);
        }
    }
}
